<?php

require_once dirname(__FILE__).'/../lib/change_logsGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/change_logsGeneratorHelper.class.php';

/**
 * change_logs actions.
 *
 * @package    sf_sandbox
 * @subpackage change_logs
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class change_logsActions extends autoChange_logsActions
{
    public function buildQuery(){
        $q = parent::buildQuery();
        $q->addGroupBy('model_name')
          ->addGroupBy('model_id')
          ->addGroupBy('version_id');
  
        return $q;
    }
    
	public function executeEdit(sfWebRequest $request){
		   $id = $this->getRequestParameter('id');
		   $this->redirect('change_logs/listViewDetails?id='.$id);
	}
    public function executeListViewDetails(sfWebRequest $request){        
        
        $id = $this->getRequestParameter('id');
        $this->rec_obj = ChangeLogsTable::getInstance()->find($id);
        
        if(!$this->rec_obj){
            $model_name = $this->getRequestParameter('model_name');
            $model_id = $this->getRequestParameter('model_id');
            
            $this->rec_obj = ChangeLogsTable::getInstance()->getLastObjectLog($model_name, $model_id);
        }
        
        if(!$this->rec_obj) return;
        
        $form_class = $this->rec_obj['model_name'].'Form';		
        $this->form = new $form_class();
        
        $this->log_recs = $this->rec_obj->getCurrentVersionRecords();
    }
}
